import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/global/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import get1 from "@dfeidao/atom-web/local/get"
import success from '@dfeidao/atom-web/msgbox/success';
import error from '@dfeidao/atom-web/msgbox/error';
import refresh from '@dfeidao/atom-web/url/refresh';
import { productid } from '../../atom/config';
import parse from '@dfeidao/atom-web/dt/parse';
export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const res2 = await nodejs<{ d1: Array<{ cust_sat: string, work_order_status: string }>, re: string }>("order-satisfaction/zj-000003/s001", "");
	//const users = get('users');
	const work_bill_no = get1(fd, 'ss');//'工单编号work_bill_no'：传入的'工单编号work_bill_no'，
	console.log("shuc", work_bill_no);
	const sadfa = "1";
	const cust_sat = res2.d1[0].cust_sat;//页面上的客户满意度，
	const record_no = res2.re;// '记录编号record_no'：依据全局编码生成，
	const visit_people ="庄开局";// '回访人visit_people'：当期登录用户的用户名称，
	const visit_phone = "13101111112";// '回访人电话visit_phone'：当前登录用户的电话，
	const IDproductid = "kinth_cloud_100";// // '产品IDproductid'：从登录的用户的信息中获取，
	const revisit_days = new Date().getTime();//'回访时间revisit_days'：当前服务器时间
	const res1 = fd.data.node.querySelector<HTMLSelectElement>("[data-id='unit']");
	const res = res1.value;
	const res3 = fd.data.node.querySelector<HTMLSelectElement>("[data-id='ress']");
	const visit_result = res3.value;//visit_result'：页面上的回访结果，
	const work_order_status = res2.d1[0].work_order_status;
	console.log("work_order_status", work_order_status);
	let score = "";//'分值score'：存页面上选择的客户满意度对应的分数“非常满意”则得40分；“满意”则得35分；“一般”得25分； “不满意”不得分；
	if (res == "1") {
		score = "40";
	} else if (res == "2") {
		score = "35";
	} else if (res == "3") {
		score = "25"
	} else if (res == "4") {
		score = "0"
	} else {
		score = "0"
	}
	const resc = await nodejs<{ code: 0 | 1; result: string }>('order-satisfaction/zj-000003/s002', {
		filter: {
			productid: IDproductid,
			work_bill_no: work_bill_no,
			visit_people: visit_people,
			score: score,
			visit_phone: visit_phone,
			revisit_days: revisit_days,
			visit_result: visit_result,
			record_no: record_no,
			cust_sat: res
		},
		filter1: {
			productid,
			work_order_status: sadfa
		}
	});
	if (resc.code == 1) {
		success("编辑成功");

	} else {
		error("编辑失败");
	}
}

